const pubVmUtil = {
  getVmStateHtml: getVmStateHtml
}

function getVmStateHtml(state, stateName) {
  let _html = ''
  // const title = this.$t("vmState[\'" + state + "\']")
  const title = stateName
  switch (state) {
    case 'RUNNING':
      _html = `<span class="iconfont icon-playcircle vm-status-running" title="${title}"></span>`
      break
    case 'STOPPED':
      _html = `<span class="iconfont icon-stopcircle vm-status-stopped" title="${title}"></span>`
      break
    case 'PAUSED':
      _html = `<span class="iconfont icon-pausecircle vm-status-paused" title="${title}"></span>`
      break
    case 'SUSPENDED':
      _html = `<span class="iconfont icon-pausecircle vm-status-suspended" title="${title}"></span>`
      break
    case 'PENDING':
      _html = `<span class="iconfont icon-loading vm-status-in-progress" title="${title}"></span>`
      break
    case 'STARTING':
    case 'STOPPING':
    case 'DELETING':
    case 'CREATING':
    case 'REBOOTING':
    case 'CONFIG_CHANGING':
    case 'TEMPLATE_CONVERTING':
    case 'SNAPSHOT_CREATING':
    case 'SNAPSHOT_REVERTING':
    case 'VOLUME_MIGRATING':
      _html = `<span class="iconfont icon-loading vm-status-in-progress" title="${title}"></span>`
      break
    case 'ERROR':
      _html = `<span class="iconfont icon-times-circle vm-status-error" title="${title}"></span>`
      break
    case 'IN_PROGRESS':
      _html = `<span class="iconfont icon-loading vm-status-in-progress" title="${title}"></span>`
      break
    case 'UNKNOWN':
      _html = `<span class="iconfont icon-question-circle vm-status-unknown" title="${title}"></span>`
      break
    default:
      _html = state
      break
  }
  return _html
}

export default pubVmUtil
